﻿using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.UI;

namespace ASPNETVN.PORTAL.Modules.SIGNIN
{
    public enum ModulePages
    {
        SignIn,
        SignOut
    }

    public partial class Main : PortalModuleControl
    {
        private void LoadChildControl()
        {
            const string basePath = "~/Modules/ASPNETVN.PORTAL.Modules.SIGNIN/";
            ModulePages page = ModulePages.SignIn;
            if (PortalSecurity.CurrentUser.Identity.IsAuthenticated)
            {
                page = ModulePages.SignOut;
            }

            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            ContentPane.Controls.Add(ctl);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.LoadChildControl();
        }
    }
}